Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking: added CAN multicast UDP network gateway #28038

Merged
merged 10 commits into from
Sep 17, 2024

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Sep 8, 2024

This allows the PPPGW peripherals to act as CAN multicast gateways, which allows any device on the ethernet network to interact with CAN devices on the flight controllers CAN networks
It also means we can configure and update the PPPGW peripherals without knowing the IP address it is configured for, as we can use DroneCAN GUI tool with interface mcast:0 or mcast:1 to get at CAN1 or CAN2 and configure parameters

This gateway is enabled in both AP_Periph with PPPGW and in the network enabled AP_Periph bootloader, which means this can also be used to update the firmware on the AP_Periph PPPGW device

This costs about 450 bytes, which comes from the change to the hal.can API to allow registration of more than one callback. We could have a new API that only appears when this option is enabled, but it would be a duplicate of the current register function, just with a new cb targets, maybe cb_mcast.

@tridge tridge force-pushed the pr-mcast-can branch 4 times, most recently from a1db65e to 071e1dc Compare September 8, 2024 10:39
@magicrub
Copy link
Contributor

magicrub commented Sep 8, 2024

You had me at update FW....

@timtuxworth
Copy link
Contributor

If I run this "behind" a Raspberry PI on the plane - so not exposing the IP address of the device directly (e.g. I use a proxy to forward the web server and mavp2p to forward the mavlink traffic over a different interface), how would I forward the CAN traffic?

@tridge
Copy link
Contributor Author

tridge commented Sep 8, 2024

how would I forward the CAN traffic?

the multicast traffic can be fwded over the link if your IP radio allows that. I'm thinking we may need to have an option to set the TTL to 1 so it doesn't get fwded

note you can use the existing network port fwding to fwd mavlink and then use mavcan

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 10, 2024

Setting up CAN on companion computers is hard. This is a nice alternative.

Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read through the PR, really neat Tridge! Just some ideas, largely NFC.
I tried to find spots for nullptr dereference and it looks good.

libraries/AP_HAL/CANIface.cpp Outdated Show resolved Hide resolved
libraries/AP_HAL/CANIface.h Show resolved Hide resolved
libraries/AP_Networking/AP_Networking_CAN.cpp Show resolved Hide resolved
libraries/AP_Networking/AP_Networking_CAN.cpp Show resolved Hide resolved
libraries/AP_Networking/AP_Networking_CAN.cpp Show resolved Hide resolved
libraries/AP_Networking/AP_Networking_CAN.h Outdated Show resolved Hide resolved
@peterbarker
Copy link
Contributor

@bugobliterator is reviewing this - hopefully done soon!

Copy link
Member

@bugobliterator bugobliterator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, except for minor change request to thread_sleep_us. That could be a future trap if someone tries to run an odd conversion frequency between ticks and seconds.

Tools/AP_Bootloader/support.cpp Show resolved Hide resolved
@tridge tridge merged commit 9cb3354 into ArduPilot:master Sep 17, 2024
95 checks passed
@robertlong13
Copy link
Collaborator

This is the PR that caused the issues with DroneCAN over MAVLink described in #28175

@robertlong13
Copy link
Collaborator

Specifically, it was either 4a102e2 or cc930bd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants